package com.xes.demo;

import org.apache.rocketmq.common.message.MessageConst;
import org.apache.rocketmq.spring.support.RocketMQHeaders;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.MessageHeaders;
import org.springframework.messaging.support.MessageBuilder;

import javax.annotation.Resource;
import java.util.stream.Collectors;
import java.util.stream.Stream;


/**
 * @program: tal-scsdemo
 * @description:
 * @author: pkn
 * @create: 2020-06-22 14:38
 */
@EnableBinding(TalSource.class)
public class TalMessageProviderImpl implements TalMessageProvider{

    @Resource
    private MessageChannel output1;

    @Resource
    private MessageChannel output2;


    @Override
    public String send() {

        boolean res1 = output1.send(
                MessageBuilder.withPayload("test message for 1").build());
        boolean res2 = output2.send(
                MessageBuilder.withPayload("test message for 2")
                        .setHeader(RocketMQHeaders.TAGS,"test").build());

        return ""+res1+" "+res2;
    }
}
